﻿using System.Diagnostics;
using System.Security.Principal;

namespace Qing.Loaders
{
    class QLoader
    {
        private static object _lock = new object();
        private static QLoader self = null;
        public static QLoader Self
        {
            get
            {
                if (self == null)
                {
                    lock (_lock)
                    {
                        if (self == null)
                        {
                            self = new QLoader();
                        }
                    }
                }
                return self;
            }
        }

        private bool isAdmin = false;
        private string path = "";
        private string Args = "";

        public int Run()
        {
            var rConfig = Config();
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = path;
            startInfo.Arguments = Args;
            if (isAdmin)
            {
                bool isRunas = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
                if (isRunas) startInfo.Verb = "runas";
            }
            Process.Start(startInfo);
            return 0;
        }

        private int Config()
        {
            return 0;
        }
    }
}
